package com.ssy.lingxi.member.merchant.model.constant;

import com.ssy.lingxi.common.language.LanguageHolder;

import java.util.Arrays;

/**
 * 下单模式枚举
 * @author 万宁
 * @version 2.0.0
 * @date 2020-09-03
 */
public enum MemberManageOrderTypeEnum {
    /**
     * 进货单下单 - 5
     */
    PURCHASE_ORDER(5, "进货单下单"),

    /**
     * 手工下单 - 6
     */
    MANUAL_ORDER(6, "手工下单"),

    /**
     * 询价报价下单 - 7
     */
    INQUIRY_QUOTATION_ORDER(7, "询价报价下单"),

    /**
     * 需求报价下单 - 8
     */
    DEMAND_QUOTATION_ORDER(8, "需求报价下单"),

    /**
     * 合并订单下单 - 9
     */
    COMBINED_ORDER(9, "合并订单下单"),

    /**
     * 渠道直采进货单下单 - 10
     */
    CHANNEL_DIRECT_ORDER(10, "渠道直采进货单下单"),

    /**
     * 渠道直采手工下单 - 11
     */
    CHANNEL_DIRECT_MANUAL_ORDER(11,"渠道直采手工下单"),

    /**
     * 渠道现货进货单下单 - 12
     */
    CHANNEL_PRODUCT_PURCHASE_ORDER(12, "渠道现货进货单下单"),

    /**
     * 渠道现货手工下单 - 13
     */
    CHANNEL_PRODUCT_MANUAL_ORDER(13, "渠道现货手工下单"),

    /**
     * 未知 - 99
     */
    UNKNOWN(99, "未知");

    MemberManageOrderTypeEnum(Integer code, String msg) {
        this.code = code;
    }

    private final Integer code;

    public Integer getCode() {
        return code;
    }

    public String getMsg() {
        return LanguageHolder.getName(this.getClass(), this.getCode());
    }

    public static MemberManageOrderTypeEnum toEnum(Integer code) {
        return Arrays.stream(MemberManageOrderTypeEnum.values()).filter(value -> value.getCode().equals(code)).findFirst().orElse(UNKNOWN);
    }
}
